主题
图片比较-完整比较 - IsSameImage
函数简介
两个图片完全比较,完全一样返回1,识别的两个图像大小必须一致。
接口名称
IsSameImageDLL调用
int IsSameImage(long ola, long imgPtr1, long imgPtr2);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| imgPtr1 | 长整数型 | 第一个OLAImage对象的地址 |
| imgPtr2 | 长整数型 | 第二个OLAImage对象的地址 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long img1 = ola.LoadImage("images/scene.png");
long img2 = ola.LoadImage("img/template.bmp");
if (img1 != 0 && img2 != 0) {
int same = ola.IsSameImage(img1, img2);
// 后续不再使用该图时释放
// 后续不再使用该对比图时释放
ola.FreeImage(img1);
ola.FreeImage(img2);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long img1 = ola.LoadImage("images/scene.png");
long img2 = ola.LoadImage("img/template.bmp");
if (img1 != 0 && img2 != 0)
{
int same = ola.IsSameImage(img1, img2);
// 后续不再使用该图时释放
// 后续不再使用该对比图时释放
ola.FreeImage(img1);
ola.FreeImage(img2);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
img1 = ola.LoadImage("images/scene.png")
img2 = ola.LoadImage("img/template.bmp")
if img1 and img2:
same = ola.IsSameImage(img1, img2)
# 后续不再使用该图时释放
ola.FreeImage(img1)
# 后续不再使用该对比图时释放
ola.FreeImage(img2)java
import com.olaplug.OLAPlugServer;
import com.olaplug.model.MatchResult;
import java.util.List;
OLAPlugServer ola = new OLAPlugServer();
long img1 = ola.LoadImage("images/scene.png");
long img2 = ola.LoadImage("img/template.bmp");
if (img1 != 0 && img2 != 0) {
ola.IsSameImage(img1, img2);
// 后续不再使用该图时释放
// 后续不再使用该对比图时释放
ola.FreeImage(img1);
ola.FreeImage(img2);
}cpp
var ola = com("OlaPlug.OlaSoft")
var img1 = ola.LoadImage("images/scene.png")
var img2 = ola.LoadImage("img/template.bmp")
if(img1 && img2) {
ola.IsSameImage(img1, img2);
// 后续不再使用该图时释放
// 后续不再使用该对比图时释放
ola.FreeImage(img1)
ola.FreeImage(img2)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
img1 = ola.LoadImage("images/scene.png")
img2 = ola.LoadImage("img/template.bmp")
If img1 <> 0 And img2 <> 0 Then
ola.IsSameImage(img1, img2);
' 后续不再使用该图时释放
' 后续不再使用该对比图时释放
ola.FreeImage(img1)
ola.FreeImage(img2)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
img1 = ola.LoadImage ("images/scene.png")
img2 = ola.LoadImage ("img/template.bmp")
ola.IsSameImage(img1, img2);
' 后续不再使用该图时释放
ola.FreeImage (img1)
' 后续不再使用该对比图时释放
ola.FreeImage (img2)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var img1 = ola.LoadImage("images/scene.png");
var img2 = ola.LoadImage("img/template.bmp");
if(img1 && img2){
ola.IsSameImage(img1, img2);
// 后续不再使用该图时释放
// 后续不再使用该对比图时释放
ola.FreeImage(img1);
ola.FreeImage(img2);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 img1 = ola.LoadImage("images/scene.png")
长整数 img2 = ola.LoadImage("img/template.bmp")
ola.IsSameImage(img1, img2);
' 后续不再使用该图时释放
' 后续不再使用该对比图时释放
ola.FreeImage(img1)
ola.FreeImage(img2)cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long img1 = ola.LoadImage("images/scene.png");
long img2 = ola.LoadImage("img/template.bmp");
if (img1 != 0 && img2 != 0) {
ola.IsSameImage(img1, img2);
// 后续不再使用该图时释放
// 后续不再使用该对比图时释放
ola.FreeImage(img1);
ola.FreeImage(img2);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
IsSameImage(instance, img1, img2);csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int IsSameImage(long ola, long ptr, long ptr2);
long instance = CreateCOLAPlugInterFace();
int same = IsSameImage(instance, img1, img2);python
from ctypes import CDLL, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
same = ola.IsSameImage(instance, img1, img2)返回值
整数型:1 成功,0 失败。
注意事项
- 两个图像大小必须一致
